from rest_framework.response import Response


class CommonResponse(Response):
    def __init__(self, state=1, tip='提示信息', data=None,
                 status=None, template_name=None, headers=None,
                 exception=False, content_type=None, **kwargs):
        new_data = {
            'state': state,
            'tip': tip
        }
        new_data.update(kwargs)
        if data:
            new_data['data'] = data
        super().__init__(data=new_data, status=None,
                         template_name=None, headers=None,
                         exception=False, content_type=None)